Skip to content

api: ContractAllMethodsGet reports the annotations of methods and arguments - #164

Merged
EnzinoBB merged 5 commits into
masterfrom
fix/api-method-annotations
Nov 3, 2026
Merged

EnzinoBB merged 5 commits into
masterfrom
fix/api-method-annotations

Conversation

@EnzinoBB

@EnzinoBB EnzinoBB commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Problem

ContractAllMethodsGet asks the executor for a contract's methods and copies only the name, the return type and each argument's type and name. The executor also returns the annotations of every method and argument (@Getter, @UsingContract, @ContractAddress, @ContractMethod, ...), but the node drops them, so a client such as the community wallet cannot tell a getter it may run for free from a method that changes the state.

Change

  • api/src/apihandler.cpp, ContractAllMethodsGet: copy MethodDescription.annotations and MethodArgument.annotations from the executor's answer.
  • No IDL change: general.thrift already has annotations on both MethodDescription (field 4) and MethodArgument (field 3), the same struct the executor returns. Clients built from the current IDL simply see the lists filled instead of empty.
  • ContractMethodsGet(address) is declared in the IDL but not implemented by the node (it falls back to APINull and returns an empty result), so it has nothing to pass on; it is left as is.

Test

ci/testnet/contracts.py compiles samples/contracts/Counter.java through node 1 and checks that ContractAllMethodsGet marks getValue, getNote and getOwner with com.credits.scapi.annotations.Getter, and not increment, add or setNote. Node 1 always runs the node under test, so the check holds with node_alt_ref=official on the even nodes too.

API only: no consensus, validation or stored data is touched.

🤖 Generated with Claude Code

EnzinoBB and others added 5 commits November 3, 2026 21:26
…uments

The executor returns every method with its annotations (@Getter, @UsingContract,
@contractaddress, @ContractMethod and the others), but ContractAllMethodsGet
copied only the name, return type and argument names and types, so a client
could not tell a getter from a method that changes the state. The annotations of
the methods and of their arguments now reach the client, in the fields the IDL
already has (general.MethodDescription.annotations, MethodArgument.annotations).

ci: contracts.py compiles samples/contracts/Counter.java and checks that
ContractAllMethodsGet marks its three getters, and only them, with @Getter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With executor_ref (mixed executors), contracts.py compiles a source with two
errors on the even nodes and prints what SmartContractCompile returns: the
compiler's errors with their line numbers once the executor has
CreditsCommunity/contract-executor#13. Reported only; nodes running the release
executor are left out, as its failure makes the node reopen its executor
connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tations

# Conflicts:
#	ci/testnet/contracts.py
#	docs/CHANGES.md
@EnzinoBB
EnzinoBB merged commit b211fb2 into master Nov 3, 2026
5 checks passed
EnzinoBB added a commit that referenced this pull request Nov 4, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant